mport java.util.Scanner;

class TreeNode {

    char val;

    TreeNode left;

    TreeNode right;

    public TreeNode(char val) {

        this.val = val;

    }

}



// 注意类名必须为 Main, 不要有任何 package xxx 信息

public class Main {

    public static int i = 0;

    public static TreeNode creatTree(String str) {

    char ch = str.charAt(i);

    i++;

    if (ch == '#') {

        return null;

    }

    TreeNode cur = new TreeNode(ch);

    cur.left = creatTree(str);

    cur.right = creatTree(str);

    return cur;

}

public static void inOrder(TreeNode root) {

    if (root == null) {

        return;

    }

    inOrder(root.left);

    System.out.print(root.val + " ");

    inOrder(root.right);

}

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String s;

        s = in.nextLine();

        TreeNode ret = creatTree(s);

        inOrder(ret);

    }

}
